package formula.web;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.apache.commons.beanutils.PropertyUtils;

import twork.business.pagefilter.PageFilterAdapter;
import twork.util.exception.TworkRuntimeException;
import formula.business.pojo.DriverFilter;

@ManagedBean
@SessionScoped
public class DriverFilterForm extends PageFilterAdapter {

	private static final long serialVersionUID = 948004401739035087L;

	private String firstname;

	private String lastname;

	private Long levelId;

	private Integer age;

	private Long teamId;

	public DriverFilterForm() {
		super();
		setSortColumnName("id");
		setPageSize(100);
	}

	public DriverFilter extractDriverFilter() {
		DriverFilter driverFilter = new DriverFilter();
		try {
			PropertyUtils.copyProperties(driverFilter, this);
		} catch (Throwable e) {
			throw new TworkRuntimeException("copy.problem", this.toString());
		}
		return driverFilter;
	}

	@Override
	public String toString() {
		return "DriverFilterForm@" + this.hashCode() + "[firstname=" + firstname + ", lastname=" + lastname
				+ ", levelId=" + levelId + ", age=" + age + ", teamId=" + teamId + "]";
	}

	public Long getTeamId() {
		return teamId;
	}

	public void setTeamId(Long _teamId) {
		teamId = _teamId;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public void setLevelId(Long levelId) {
		this.levelId = levelId;
	}

	public Long getLevelId() {
		return levelId;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public Integer getAge() {
		return age;
	}

	public void clear() {
		age = null;
		firstname = null;
		lastname = null;
		levelId = null;
		teamId = null;
	}
}
